/**
 * Created by liguangsong on 16/8/3.
 */
import { CLICK_ARROW, REFRESH_INDEX } from '../action/index.js'

function initialState() {
    return {
        index: 0
    }
}

function clickArrow(state=initialState(), action) {
    switch(action.type) {
        case CLICK_ARROW: {
            if (action.arrow === 'left') {
                var index = state.index;
                return {
                    index: index + 1
                }
            }
            else {
                var index = state.index;
                return {
                    index: index - 1
                }
            }
        }
        case REFRESH_INDEX: {
            return {
                index: 0
            }
        }
        default :
            return state;
    }
}

export default clickArrow;